<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Git提交对象解析 | 技术小馆</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            line-height: 1.8;
            color: #333;
            background-color: #f9f9f9;
        }
        h1, h2, h3 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
        }
        .hero {
            background: linear-gradient(135deg, #2b5876 0%, #4e4376 100%);
            color: white;
        }
        .card {
            transition: all 0.3s ease;
            border-radius: 8px;
            overflow: hidden;
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0,0,0,0.1);
        }
        .icon-circle {
            width: 60px;
            height: 60px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 1rem;
        }
        .highlight-box {
            position: relative;
            padding-left: 1.5rem;
            border-left: 4px solid #4e4376;
            background-color: rgba(78, 67, 118, 0.05);
        }
        .diagram-container {
            background-color: white;
            border-radius: 8px;
            padding: 2rem;
            box-shadow: 0 4px 15px rgba(0,0,0,0.05);
        }
        footer {
            background-color: #1a1a1a;
            color: #e0e0e0;
        }
        .footer-link:hover {
            color: #a0a0a0;
        }
        .scroll-animate {
            opacity: 0;
            transform: translateY(20px);
            transition: all 0.6s ease-out;
        }
        .animate {
            opacity: 1;
            transform: translateY(0);
        }
        @media (max-width: 768px) {
            .hero-content {
                text-align: center;
            }
            .feature-icon {
                margin-left: auto;
                margin-right: auto;
            }
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-6xl px-4 flex flex-col md:flex-row items-center">
            <div class="hero-content md:w-1/2 mb-10 md:mb-0 md:pr-10 scroll-animate">
                <h1 class="text-3xl md:text-4xl lg:text-5xl font-bold mb-4">深入理解Git提交对象</h1>
                <p class="text-xl mb-6 opacity-90">揭秘版本控制的核心数据结构</p>
                <p class="mb-8 opacity-85">提交对象是Git版本控制系统的基石，它记录了每次代码提交的快照和相关信息。让我们一起探索这个强大而精妙的系统如何管理我们的代码历史。</p>
                <div class="flex flex-wrap gap-4">
                    <a href="#content" class="bg-white text-indigo-800 px-6 py-3 rounded-lg font-medium hover:bg-gray-100 transition">开始探索</a>
                    <a href="#diagram" class="bg-transparent border-2 border-white text-white px-6 py-3 rounded-lg font-medium hover:bg-white hover:text-indigo-800 transition">查看图解</a>
                </div>
            </div>
            <div class="md:w-1/2 scroll-animate">
                <img src="https://images.unsplash.com/photo-1639762681057-408e52192e55?q=80&w=2232&auto=format&fit=crop" alt="Git版本控制" class="rounded-lg shadow-xl w-full h-auto">
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <section id="content" class="py-16 px-4">
        <div class="container mx-auto max-w-4xl">
            <div class="text-center mb-16 scroll-animate">
                <h2 class="text-3xl font-bold mb-4">Git提交对象的组成部分</h2>
                <p class="text-lg text-gray-600 max-w-2xl mx-auto">每个Git提交对象都包含7个关键元素，共同构成了版本控制的基础</p>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-20">
                <!-- Card 1 -->
                <div class="card bg-white p-6 shadow-md scroll-animate">
                    <div class="icon-circle bg-indigo-100 text-indigo-700 mx-auto feature-icon">
                        <i class="fas fa-comment-dots text-2xl"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3 text-center">提交信息</h3>
                    <p class="text-gray-700 mb-3">提交时用户输入的消息，描述了这次提交的目的或更改内容。</p>
                    <div class="highlight-box p-3">
                        <p class="text-sm text-gray-600"><strong>作用：</strong>帮助其他开发者理解这次提交的意图和修改了哪些内容。</p>
                    </div>
                </div>

                <!-- Card 2 -->
                <div class="card bg-white p-6 shadow-md scroll-animate">
                    <div class="icon-circle bg-blue-100 text-blue-700 mx-auto feature-icon">
                        <i class="fas fa-folder-tree text-2xl"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3 text-center">树对象</h3>
                    <p class="text-gray-700 mb-3">提交对象指向一个树对象，这个树对象代表了提交时工作目录的状态。</p>
                    <div class="highlight-box p-3">
                        <p class="text-sm text-gray-600"><strong>作用：</strong>描述了提交时所有文件和目录的层级结构。</p>
                    </div>
                </div>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-20">
                <!-- Card 3 -->
                <div class="card bg-white p-6 shadow-md scroll-animate">
                    <div class="icon-circle bg-purple-100 text-purple-700 mx-auto feature-icon">
                        <i class="fas fa-code-branch text-2xl"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3 text-center">父提交</h3>
                    <p class="text-gray-700 mb-3">提交对象包含一个或多个指向父提交对象的引用。</p>
                    <div class="highlight-box p-3">
                        <p class="text-sm text-gray-600"><strong>作用：</strong>记录了当前提交的历史链，帮助Git追踪版本历史。</p>
                    </div>
                </div>

                <!-- Card 4 -->
                <div class="card bg-white p-6 shadow-md scroll-animate">
                    <div class="icon-circle bg-green-100 text-green-700 mx-auto feature-icon">
                        <i class="fas fa-user-edit text-2xl"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3 text-center">作者信息</h3>
                    <p class="text-gray-700 mb-3">提交时的作者姓名和电子邮件地址，以及提交时间。</p>
                    <div class="highlight-box p-3">
                        <p class="text-sm text-gray-600"><strong>作用：</strong>提供有关谁进行了这次提交的详细信息。</p>
                    </div>
                </div>
            </div>

            <div class="grid md:grid-cols-2 gap-8">
                <!-- Card 5 -->
                <div class="card bg-white p-6 shadow-md scroll-animate">
                    <div class="icon-circle bg-yellow-100 text-yellow-700 mx-auto feature-icon">
                        <i class="fas fa-user-tie text-2xl"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3 text-center">提交者信息</h3>
                    <p class="text-gray-700 mb-3">提交者姓名和电子邮件地址，以及提交时间。</p>
                    <div class="highlight-box p-3">
                        <p class="text-sm text-gray-600"><strong>作用：</strong>记录了实际提交更改到仓库的人的信息。</p>
                    </div>
                </div>

                <!-- Card 6 -->
                <div class="card bg-white p-6 shadow-md scroll-animate">
                    <div class="icon-circle bg-red-100 text-red-700 mx-auto feature-icon">
                        <i class="fas fa-clock text-2xl"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3 text-center">提交时间</h3>
                    <p class="text-gray-700 mb-3">提交的时间戳，记录了提交操作完成的实际时间。</p>
                    <div class="highlight-box p-3">
                        <p class="text-sm text-gray-600"><strong>作用：</strong>为提交对象添加时间上下文。</p>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Diagram Section -->
    <section id="diagram" class="py-16 px-4 bg-gray-50">
        <div class="container mx-auto max-w-4xl">
            <div class="text-center mb-12 scroll-animate">
                <h2 class="text-3xl font-bold mb-4">Git提交对象结构关系图</h2>
                <p class="text-lg text-gray-600 max-w-2xl mx-auto">使用Mermaid.js展示提交对象及其相关组件之间的关系</p>
            </div>

            <div class="diagram-container scroll-animate">
                <div class="mermaid">
                    graph TD
                    A[提交对象Commit Object] --> B[提交信息Commit Message]
                    A --> C[树对象Tree Object]
                    A --> D[父提交Parent Commits]
                    A --> E[作者信息Author]
                    A --> F[提交者信息Committer]
                    A --> G[提交时间Date]
                    A --> H[哈希值SHA-1]
                    C --> I[文件1 blob]
                    C --> J[文件2 blob]
                    C --> K[目录1 tree]
                    K --> L[文件3 blob]
                </div>
            </div>
        </div>
    </section>

    <!-- Additional Info -->
    <section class="py-16 px-4">
        <div class="container mx-auto max-w-4xl">
            <div class="card bg-white p-8 shadow-lg scroll-animate">
                <h2 class="text-2xl font-bold mb-6">Git提交对象的关键特性</h2>
                <div class="grid md:grid-cols-2 gap-8">
                    <div>
                        <h3 class="text-lg font-semibold mb-3 text-indigo-700 flex items-center">
                            <i class="fas fa-fingerprint mr-2"></i> 不可变性
                        </h3>
                        <p class="text-gray-700 mb-6">一旦创建，提交对象就不可更改。任何修改都会生成一个新的提交对象。这是Git版本控制安全性的基础。</p>

                        <h3 class="text-lg font-semibold mb-3 text-indigo-700 flex items-center">
                            <i class="fas fa-link mr-2"></i> 链式结构
                        </h3>
                        <p class="text-gray-700 mb-6">通过父提交引用，提交对象形成有向无环图(DAG)，允许精确追踪历史记录。</p>
                    </div>
                    <div>
                        <h3 class="text-lg font-semibold mb-3 text-indigo-700 flex items-center">
                            <i class="fas fa-hashtag mr-2"></i> 唯一标识
                        </h3>
                        <p class="text-gray-700 mb-6">SHA-1哈希确保了每个提交对象的全球唯一性，同时验证了内容的完整性。</p>

                        <h3 class="text-lg font-semibold mb-3 text-indigo-700 flex items-center">
                            <i class="fas fa-sitemap mr-2"></i> 分层存储
                        </h3>
                        <p class="text-gray-700">树对象和blob对象的分层设计实现了高效的文件存储和版本控制。</p>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Footer -->
    <footer class="py-12 px-4">
        <div class="container mx-auto max-w-4xl text-center">
            <h3 class="text-xl font-medium mb-4">技术小馆</h3>
            <p class="mb-6">探索技术之美，分享知识之光</p>
            <a href="http://www.yuque.com/jtostring" class="footer-link hover:underline">http://www.yuque.com/jtostring</a>
        </div>
    </footer>

    <!-- Scripts -->
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <script>
        // Initialize Mermaid
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });

        // Scroll animation
        document.addEventListener('DOMContentLoaded', function() {
            const scrollElements = document.querySelectorAll('.scroll-animate');
            
            const elementInView = (el) => {
                const elementTop = el.getBoundingClientRect().top;
                return (
                    elementTop <= (window.innerHeight * 0.75)
                );
            };
            
            const displayScrollElement = (element) => {
                element.classList.add('animate');
            };
            
            const handleScrollAnimation = () => {
                scrollElements.forEach((el) => {
                    if (elementInView(el)) {
                        displayScrollElement(el);
                    }
                });
            };
            
            // Initialize
            scrollElements.forEach((el) => {
                if (elementInView(el)) {
                    displayScrollElement(el);
                }
            });
            
            window.addEventListener('scroll', () => {
                handleScrollAnimation();
            });
        });
    </script>
</body>
</html>